package bard.partnermatchingsystem.config;

import lombok.Data;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@ConfigurationProperties(prefix = "spring.redis")
@Configuration
@Data
public class RedissonConfig {
    private String host;
    private String port;
    @Bean
    public RedissonClient redissonClient() {
        Config config=new Config();
        String address =String.format("redis://%s:%s", host, port) ;
        // 单机
        config.useSingleServer().setAddress(address).setDatabase(6);
        RedissonClient redisson = Redisson.create(config);
        return redisson;
    }
}
